<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.ahp.bean.Factor"%>
<%@ include file="../include/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>选择模板</title>
<script type="text/javascript" src="<%=path %>/js/jquery-1.3.2.js"></script>
<link rel="stylesheet" href="<%=path%>/style/style_manage.css" type="text/css"></link>
<style type="text/css">
.added{border: 1px solid gray; margin: 1em 1em; padding: 5px 8px;}
.delSpan{cursor: pointer;}
div{line-height: 150%;}
</style>
<script type="text/javascript">
divide = function(){
	var fir = $("#first").val();
	var sec = $("#second").val();
	if(fir.length<1 || sec.length<1){
		alert("请填写被除数或除数！");
		return false;
	}
	try{
		var result = parseInt(fir)/parseInt(sec);
		var tmp = result+"";
		if(tmp.length>5){
			tmp = tmp.substring(0,5);
		}
		$("#divResult").val(tmp);
	}catch(err){
		alert("请填写整数！");
		return fasle;
	}
}
checkFactors = function(){
	var b = true;
	$(".factor").each(function(){
		if($(this).val().length<1){
			alert("请填写因子权重！");
			b = false;
			return false;
		}
		try{
			//alert(Number($(this).val()));
			if(isNaN(Number($(this).val()))){
				b=false;
				return false;
			}
		}catch(err){
			alert("权重必须为数值！");
			b = false;
			return fasle;
		}
	});
	alert("ok" + b);
}
</script>
</head>
<body>
<div id="management">
	<h1 style="position: relative;">录入一级因子</h1>
	<div id="result" style="color:red;"></div>
	<div>您只需要录入上三角矩阵的数据，所给的数据为1-9整数，或者大于0且小于1的小数。采用1-9标度方法。下方为小数的计算器。</div>
	<div align="center"><input type="text" name="first" id="first" value="" size="8" /> / 
		<input type="text" name="second" id="second" value="" size="8" /> = 
		<input type="text" name="divResult" id="divResult" value="" size="8" style="border: solid 1px red; width: 60px; height: 20px;"/> &nbsp;
		<input type="button" onclick="divide();" value="计算" /></div>
	<%
	List<Factor> oneList = null;
	int size = 0;
	int mark = 1;
	if(request.getAttribute("levOneList")!=null){
		oneList = (List<Factor>)request.getAttribute("levOneList");
		size = oneList.size();
	}
	%>
	<table border="1" class="table">
	  <tr>
	  	<td></td>
	  	<%
		for(Factor fac : oneList){
		%><td><%=fac.getName() %></td><%
		}
		%>
	  </tr>
		<%
		for(Factor fac : oneList){
		%>
		<tr>
			<td><%=fac.getName() %></td>
			<%
				for(int i = 0 ; i < mark; i ++){
					%><td style="background-color: #c9c9c9;"></td><%
				}
				for(int i = 0 ; i < size - mark; i ++){
					%><td><input type="text" value="" name="factor" class="factor"/></td><%
				}
			%>
		</tr>
		<%
		mark++;
		}
		%>
	</table>
	<div align="center"><input type="button" onclick="checkFactors();" value="下一步" /> </div>
</div>
</body>
</html>